package com.open.capacity.finance.controller;

import com.open.capacity.commons.Result;
import com.open.capacity.finance.config.Globals;
import com.open.capacity.user.model.SysCompany;
import com.open.capacity.utils.DateUtil;
import com.open.capacity.vo.TreeVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.collections.list.TreeList;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;


/**
 * 系统
 *
 * @author
 * @email
 * @date 2020-06-03 22:56:51
 */
@RestController
@RequestMapping("systems")
@Api(tags = "系统属性")
public class SystemController {

    @Value(value = "${system.version:1.0.2}")
    private String version;

    /**
     * 系统版本
     */
    @RequestMapping("/version")
    public Result version() {
        return Result.succeed("1.0.2", "获取成功");
    }

    /**
     * 清空缓存
     */
    @RequestMapping("/clearCache")
    public Result clearCache() {
        return Result.succeed("清空缓存成功");
    }


    @GetMapping("/listKjnds")
    public Result<List<TreeVo>> listKjnds() {
        List<TreeVo> treeList = new ArrayList<>();
        for (int i = DateUtil.getYear() - 3; i <= DateUtil.getYear(); i++) {
            TreeVo node = new TreeVo();
            node.setId(String.valueOf(i));
            node.setText(String.valueOf(i));
            node.setTitle(String.valueOf(i));
            node.setValue(String.valueOf(i));
            node.setShowcheck(false);
            node.setCheckstate(0);
            node.setIsexpand(false);
            node.setComplete(true);
            node.setParentId("0");
            treeList.add(node);
        }

        return Result.succeed(treeList);
    }

}
